package com.itheima.controller;

import com.itheima.pojo.Book;
import com.itheima.pojo.User;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Xiao
 * @date 2021/9/15
 */
@RestController
@RequestMapping("/bookCases")
public class BookCaseController {
    @PostMapping
    public String save(@RequestBody Book book) {
        System.out.println(book);
        return "{'module':'book save success...'}";
    }
    @GetMapping
    public List<Book> queryAll() {
        Book book1 = new Book();
        book1.setType("计算机");
        book1.setName("SpringMVC入门教程");
        book1.setDescription("小试牛刀");
        Book book2 = new Book();
        book2.setType("计算机");
        book2.setName("SpringMVC实战教程");
        book2.setDescription("一代宗师");
        Book book3 = new Book();
        book3.setType("计算机");
        book3.setName("SpringMVC高级教程");
        book3.setDescription("独孤求败");
        List<Book> list = new ArrayList<>(List.of(book1, book2, book3));
        System.out.println(list);
        return list;
    }
}
